//2009/08/26 02:30:18
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <sstream>
#include <algorithm>

using namespace std;

class PunctuationCleaner
{
public:
    string clearExcess(string document)
    {
        string ret;
        int flag = 0;
        for (int i=0; i<document.size(); i++)
        {
            if (document[i] == '!')
            {
                flag = max(1, flag);
            }
            else if (document[i] == '?') flag = 2;
            else
            {
                if (flag == 0) ret += document[i];
                else if (flag == 1)
                {
                    ret += '!';
                    ret += document[i];
                }
                else
                {
                    ret += '?';
                    ret += document[i];
                }
                flag = 0;
            }
        }
        if (flag == 1) ret += '!';
        else if (flag == 2) ret += '?';
        return ret;
    }
};
